package com.blb.ioc.demo3;

/**
 * 计算机
 */
public class Computer {

    //品牌
    @MyValue("大米")
    private String brand;
    //cpu
    @MyComponent(AmdCpu.class)
    private Cpu cpu;
    //内存
    @MyComponent(KingstonMemory.class)
    private Memory memory;

    public Computer() {
        System.out.println("无参构造方法");
    }

    public Computer(String brand, Cpu cpu, Memory memory) {
        System.out.println("执行有参构造方法");
        this.brand = brand;
        this.cpu = cpu;
        this.memory = memory;
    }

    public Cpu getCpu() {
        return cpu;
    }

    public void setCpu(Cpu cpu)
    {
        System.out.println("执行了setCpu");
        this.cpu = cpu;
    }

    public Memory getMemory() {
        return memory;
    }

    public void setMemory(Memory memory) {
        this.memory = memory;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    /**
     * 启动
     */
    public void start(){
        System.out.println(brand + "电脑启动了");
        cpu.run();
        memory.read();
        memory.write();
    }
}
